Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace android.os.Looper by android.os.HandleThread to prevent blocking main thread #825

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

JoBolNex
Copy link

@JoBolNex JoBolNex commented Jan 17, 2025

This PR improves the handling of background threads for legacy phone state listening on Android versions below S (API 31). Key changes:

  • Replaced the manual Looper management with a dedicated HandlerThread
  • Added proper cleanup of the HandlerThread by implementing quitSafely() when stopping the listener
  • Moved HandlerThread to a class property to ensure proper lifecycle management and prevent potential memory leaks
  • Removed the blocking Looper.loop() call which could cause issues on the calling thread

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant